home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000077_icon-group-sender_Fri Oct 18 17:06:53 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9J06oc29339
  4.     for icon-group-addresses; Fri, 18 Oct 2002 17:06:51 -0700 (MST)
  5. Message-Id: <200210190006.g9J06oc29339@baskerville.CS.Arizona.EDU>
  6. X-Zen-Trace: 62.3.105.86
  7. From: Robert Parlett <r.parlett@zen.co.uk>
  8. To: "Boulet, Dan" <BouleDa@navcanada.ca>,
  9.    "IconGroup (E-mail)" <icon-group@cs.arizona.edu>,
  10.    "Unicon Group (E-mail)" <unicon-group@lists.sourceforge.net>
  11. Subject: Re: [Unicon-group] recursive generators
  12. Date: Fri, 18 Oct 2002 22:33:13 +0100
  13. User-Agent: KMail/1.4.1
  14. Errors-To: icon-group-errors@cs.arizona.edu
  15. Status: RO
  16.  
  17. On Friday 18 October 2002 8:30 pm, Boulet, Dan wrote:
  18. > This is an appeal to all experts in recursive generation.  Given the
  19. > following string:
  20. >
  21. > astring :=
  22. > "[main],a,b,c,d,[a],a1,[b],b1,b2,[c],c1,c2,c3,[d],1,2,3,[a1],a11,a12,a13,[b
  23. >1 ],b11,b12,b13,b14,[b2],b21,b22,b23,b24,[a11],x,y,z"
  24. >
  25. > Does anyone have any ideas on how the following sub-strings can be
  26. > generated:
  27. >
  28. > main,a,a1,a11,x
  29. > main,a,a1,a11,y
  30. > main,a,a1,a11,z
  31. > main,a,a1,a12
  32. > main,a,a1,a13
  33. > main,b,b1,b11
  34. > main,b,b1,b12
  35. > main,b,b1,b13
  36. > main,b,b1,b14
  37. > main,b,b2,b21
  38. > main,b,b2,b22
  39. > main,b,b2,b23
  40. > main,b,b2,b24
  41. > main,c,c1
  42. > main,c,c2
  43. > main,c,c3
  44. > main,d,1
  45. > main,d,2
  46. > main,d,3
  47. >
  48. > note that:
  49. > main points to a,b,c
  50. > a points to a1
  51. > a1 points to a11,a12,a13
  52. > a11 points to x,y,z
  53. > b points to b1,b2
  54. > etc ...
  55. >
  56. >
  57. > Regards,
  58. >
  59. > Daniel J. Boulet
  60. > NAV CANADA
  61. > Systems Test Specialist
  62. > C113-4
  63. > (613) 248-7221
  64.  
  65. If you do put your string into a convenient data structure (eg a table of 
  66. lists), then the generator is very simple
  67.  
  68. Hope this helps.
  69.  
  70.  
  71. procedure generate_lines(t, s)
  72.    if member(t, s) then
  73.       suspend s || "," || generate_lines(t, !t[s])
  74.    else
  75.       return s
  76. end
  77.  
  78. procedure get_table()
  79.    local t
  80.  
  81.    t := table()
  82.    
  83.    t["main"] := ["a","b","c","d"]
  84.    t["a"] := ["a1"]
  85.    t["b"] := ["b1","b2"]
  86.    t["c"] := ["c1","c2","c3"]
  87.    t["d"] := ["1","2","3"]
  88.    t["a1"] := ["a11","a12","a13"]
  89.    t["b1"] := ["b11","b12","b13","b14"]
  90.    t["b2"] := ["b21","b22","b23","b24"]
  91.    t["a11"] := ["x","y","z"]
  92.  
  93.    return t
  94. end
  95.  
  96. procedure main()
  97.    every write(generate_lines(get_table(), "main"))
  98. end
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.